package com.zkthink.ceres.finance.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zkthink.base.R;
import com.zkthink.base.request.PageParams;
import com.zkthink.ceres.finance.dto.*;
import com.zkthink.ceres.finance.entity.JournalDetail;
import com.zkthink.ceres.finance.service.JournalDetailService;
import com.zkthink.log.annotation.SysLog;
import com.zkthink.security.annotation.PreAuth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 流水明细表
 * </p>
 *
 * @author vivi.huang
 * @date 2020-05-25
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/journalDetail")
@Api(value = "JournalDetail", tags = "流水明细表")
//@PreAuth(replace = "journalDetail:")
@AllArgsConstructor
public class JournalDetailController {

    private JournalDetailService journalDetailService;

    /**
     * 商家端-财务汇总分页列表查询
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "财务汇总分页列表查询")
    @PostMapping(value = "/page/summary")
    @SysLog(value = "'分页列表查询:第' + #params?.current + '页, 显示' + #params?.size + '行'", response = false)
    @PreAuth("hasPermit('{}view')")
    public R<IPage<JournalSummaryDTO>> findJournalSummaryPage(@RequestBody @Validated PageParams<JournalSummaryPageDTO> params) {
        return journalDetailService.findJournalSummaryPage(params);
    }

    /**
     * 商家端-流水明细分页列表查询
     *
     * @param params
     * @return
     */
    @ApiOperation(value = "流水明细分页列表查询")
    @PostMapping(value = "/page/detail")
    @SysLog(value = "'分页列表查询:第' + #params?.current + '页, 显示' + #params?.size + '行'", response = false)
    @PreAuth("hasPermit('{}view')")
    public R<IPage<JournalDetail>> findJournalDetailPage(@RequestBody @Validated PageParams<JournalDetailPageDTO> params) {
        return journalDetailService.findJournalDetailPage(params);
    }

    /**
     * 商家端-帐目情况
     *
     * @return
     */
    @ApiOperation(value = "帐目情况")
    @PostMapping(value = "/account-summary")
    @SysLog(value = "帐目情况", response = false)
    @PreAuth("hasPermit('{}view')")
    public R<AccountSummaryDTO> getAccountSummaryDTO() {
        return journalDetailService.getAccountSummary();
    }


    /**
     * 平台端-财务管理-统计分页
     *
     * @return
     */
    @ApiOperation(value = "平台财务管理分页列表")
    @PostMapping(value = "/platform-finance-page")
    @SysLog(value = "平台财务管理分页列表", response = false)
    @PreAuth("hasPermit('{}view')")
    public R<IPage<PlatformFinanceDTO>> getPlatformFinanceDTOPage(@RequestBody @Validated PageParams<PlatformFinanceDTO> params) {
        return journalDetailService.getPlatformFinanceDTOPage(params);
    }

    /**
     * 平台端-财务管理-总统计
     *
     * @return
     */
    @ApiOperation(value = "平台财务管理-总统计")
    @PostMapping(value = "/platform-finance-summary")
    @SysLog(value = "平台财务管理-总统计", response = false)
//    @PreAuth("hasPermit('{}view')")
    public R<PlatformFinanceDTO> getPlatformFinanceSummary() {
        return journalDetailService.getPlatformFinanceSummary();
    }




}
